home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.650 < prev    next >
Text File  |  1992-02-06  |  3KB  |  45 lines

  1. {\rtf0\ansi{\fonttbl\f3\fnil Times-Roman;\f0\fmodern Courier;}
  2. \paperw11440
  3. \paperh9000
  4. \margl120
  5. \margr120
  6. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f3\b0\i0\ul0\fs28 DPSclient Timed Entries\
  7. \
  8. Q:  I want my application to perform an operation automatically, periodically.  For instance, I want to save a backup file every 5 minutes, or I want to create a blinking cursor.  How do I go about doing that?  Should I use timer events?\
  9. \
  10. A:  What you actually want is a timed entry.  The Display PostScript routines 
  11. \b DPSAddTimedEntry
  12. \b0 () and 
  13. \b DPSRemoveTimedEntry
  14. \b0 () are used to start and stop timed entries. These functions are described in the Next Developer Documentation in the DPS section.  You install a timed entry to run at a specific interval and give a handler function which will be called at each interval.  What actually happens is that for each cycle of the event loop, the application checks to see if there are any timed entries which are due.  If so, then the handler function is called, thus "cutting" in line in front of any other events.  Timed entries are “coalesced” in a sense because the next occurrence of a timed entry is set when the current entry is processed.  There is never more than one occurrence of a timed entry waiting to run and since timed entries aren't inserted into the event queue, you don't have to worry about timed entries overflowing the queue.\
  15. \
  16. Timer events are not the correct thing to use in this instance, because they are intended to be used in modal loops.  Each application has an event queue, where pending events are waiting to be processed.  Each application has a main loop which simply polls for events, and then reacts accordingly.  Modal loops allow you to create a loop which is secondary to the application loop, and supercedes it for a short time.  You use modal loops when you have received one event and are then waiting for another which then terminates the modal loop.  The modal loop must ensure that it will continue to get a continuous stream of events, and it does this with timer events.  You use timer events in a modal loop in case the user is doing something that is not generating events (such as holding down the mouse button, and not moving it).  \
  17.  
  18. \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320 \
  19.  
  20. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 There are several programming examples that use timed en
  21. \fs24 t
  22. \fs28 ries.  If you want a simple example of a timed entry, see the 
  23. \b BusyBox
  24. \b0  example under
  25. \b  /NextDeveloper/Examples
  26. \b0 .  The 
  27. \b ClockView
  28. \b0  class there uses a timed entry to animate the movement of the hands.  Another example, the 
  29. \b ToolInspector
  30. \b0 , under 
  31. \b /NextDeveloper/Examples
  32. \b0 , uses the 
  33. \b Animator
  34. \b0  class which shows how to create an "adjusting" timed entry, which is a bit more complex.  [Tip: It can be very helpful to drag 
  35. \b /NextDeveloper/Examples
  36. \b0  into your Digital Librarian and index it.  Another useful one is 
  37. \b /usr/include
  38. \b0 .]
  39. \fs24 \
  40.  
  41. \fs28 \
  42. QA650\
  43. \
  44.  
  45.